<?php

namespace App\Model\DesignPattern\Creational\Behavioral\State;

class TextEditor
{
    protected $writingState;

    public function __construct(WritingState $writingState)
    {
        $this->writingState = $writingState;
    }

    //  重新设置 构造函数下面的
    public function setState(WritingState $writingState) //
    {
        $this->writingState = $writingState;
    }

    public function type($words)
    {
        return $this->writingState->write($words);
    }
}
